import { Directive } from '@angular/core';
import { AbstractControl } from '@angular/forms';

@Directive({
    selector: '[appPhoneValid]'
})
export class PhoneValidDirective {

    constructor() { }

}

export function phoneValidator(control: AbstractControl) {
    const regPhone = /^(1[3-9][0-9])\d{8}$/;
    if (control.value) {
        let _r = regPhone.test(control.value);
        return !_r ? { "phone": true } : null
    }else{
        return null
    }
}


